﻿@using HXDNB.DAL;
<div class="container-fluid">
    <div class="row-fluid">
        <div class="span12">
            <div class="widget-box">
                <form action="@Url.Action("List", "System")" method="post">
                <div class="widget-title">
                    <span class="icon"><i class="icon-th"></i></span>
                    <h5>
                        日志信息列表</h5>
                </div>
                <div class="widget-content" style="height: 25px;">
                    <input type="button" value="日志清理" class="btn btn-danger fl" onclick="Deletes()" />
                    <div class="span2">
                        <select name="type">
                            <option value="ALL" @Html.Raw(Request.Form["type"] == "ALL" ? "selected=\"selected\"" : "")>
                                全部日志</option>
                            @foreach (string item in Enum.GetNames(typeof(LogType)))
                            {
                                <option value="@item" @Html.Raw(item == Request.Form["type"] ? "selected=\"selected\"" : "")>
                                    @item
                                </option>
                            }
                        </select>
                    </div>
                    <button type="submit" class="btn btn-info fl" onclick="return Search();">
                        搜 索</button>
                </div>
                <div class="widget-content">
                    <table class="table table-bordered table-striped with-check">
                        <thead>
                            <tr>
                                <th>
                                    ID
                                </th>
                                <th>
                                    类型
                                </th>
                                <th>
                                    内容
                                </th>
                                <th>
                                    操作结果
                                </th>
                                <th>
                                    页面地址
                                </th>
                                <th>
                                    IP地址
                                </th>
                                <th>
                                    操作人
                                </th>
                                <th>
                                    操作时间
                                </th>
                            </tr>
                        </thead>
                        <tbody>
                            @foreach (HXDNB.DAL.Log item in ViewBag.PagList.DataList)
                            {
                                <tr>
                                    <td>
                                        @item.Id
                                    </td>
                                    <td>
                                        @item.Type
                                    </td>
                                    <td>
                                        @if (item.Message.Contains("[#"))
                                        {
                                            <span class="tip-bottom" 
                                                data-original-title="@Html.Raw("原因：" + item.Message.Substring(item.Message.IndexOf("[#")).Replace("[#", "").Replace("#]", ""))">
                                                @item.Message.Substring(0, item.Message.IndexOf("[#"))</span>                                            
                                        }
                                        else
                                        {
                                            @item.Message
                                        }
                                    </td>
                                    <td style="text-align: center">
                                        @Html.Raw(item.Result == "True" ? "<span class=\"badge badge-success\">成 功</span>" : "<span class=\"badge badge-warning\">失 败</span>")
                                    </td>
                                    <td>
                                        @item.Location
                                    </td>
                                    <td>
                                        @item.Ip
                                    </td>
                                    <td>
                                        @item.DoUser
                                    </td>
                                    <td>
                                        @item.DateTime
                                    </td>
                                </tr>
                            }
                        </tbody>
                    </table>
                    @Html.Partial("_Paging")
                </div>
                </form>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    //批量删除栏目
    function Deletes() {
        if (confirm("确认删除三个月之外的所有日志?")) {
            $("#LoadingBox").show();
            $.post('@Url.Action("Delete", "System")', function (d) {
                $("#LoadingBox").hide();
                //刷新页面，页码变为第一页
                $('#PageIndex').val(1);
                $("form").submit();
            })
        }
    }
</script>
